#ifndef GIFPLAYER_H
#define GIFPLAYER_H
#include "mainwindow.h"

class GifPlayer : public QLabel
{
    Q_OBJECT
public:
    explicit GifPlayer(const QString &gifPath, QWidget *parent = nullptr);

    void play();               // 从头开始播放
    void pause();              // 暂停
    void seek(int frameIndex); // 跳到指定帧并继续按原节奏播放
    int  frameCount() const    { return frames_.size(); }

private slots:
    void showNextFrame();

private:
    QVector<QImage>  frames_;
    QVector<int>     delays_;      // 每帧时长 ms
    int              idx_ = 0;     // 当前帧索引
    QTimer           timer_;
};

#endif // GIFPLAYER_H
